<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<html:xhtml />
<script type="text/javaScript">
    function showAssociation() {
        geneArray = $("div.leftMenu select").val();
        gene = geneArray[0];
        for (i = 1; i < geneArray.length; i++)
        {
            gene += "\n" + geneArray[i];
        }
        $("#pvalueModal").load("<html:rewrite page="/assocSearchSubmit.do" /> #ajaxContent",
                               {chkGene: 'on',
                                genes: gene,
                                submitType: 'Search',
                                noCache: Math.random()},
                                function(response, status, xhr) {
                                    if(status == "error")
                                    {
                                        $("#pvalueModal").html(xhr.status + " " + xhr.statusText);
                                    }
                                    $("#pvalueModal").dialog("option", "height", 'auto');
                                    $("#pvalueModal").dialog("open");
                                });
    }

    $(document).ready(function() {
        $("#pvalueModal").dialog({
           autoOpen: false,
           position: "top",
           modal: true,
           width: 775
        });

        $(":radio").click(function() {
            showGeneDiv();
        });
        showGeneDiv();
    });
</script>
<div id="keggPathway" class="content pathway">
    <html:form action="searchSubmit">
        <div class="input">
            <dl>
                <dt>Search KEGG Pathways:</dt>
                <dd><html:text property="searchText" />&nbsp;<html:submit property="submitType" value="Search" /></dd>
            </dl>
            <html:hidden property="searchSelect" value="3" />
        </div>
    </html:form>
    <h2>KEGG Pathway</h2>
    <div class="leftMenu">
        <p><bean:message key="pathway.gene" />:</p>
        <html:errors property="genes" />
        <html:form action="keggPathwaySubmit">
            <div>
                <html:select property="geneNames" size="8" multiple="multiple">
                    <logic:iterate id="gene" name="pathwayForm" property="geneList">
                        <option value="<bean:write name="gene" property="name"/>"><bean:write name="gene" property="name"/></option>
                    </logic:iterate>
                </html:select>
                <html:hidden value="custom" property="source" />
                <html:submit value="SNP List" property="submitType" />
                <html:button value="Associations" property="submitType" onclick="showAssociation();" />
                <html:submit value="Gene Gene Interaction" property="submitType" />
            </div>
        </html:form>
    </div>
    <div class="rightChart">
        <div class="diagram">
            <a title="Click to see the larger image." href="<bean:write name="keggPathwayForm" property="URL" />" target="_blank">
                <img id="keggPathway" src="<bean:write name="keggPathwayForm" property="URL" />" alt="Kegg Pathway" />
            </a>
        </div>
    </div>
</div>
<div id="pvalueModal" title="Association"></div>